<?php
$doller = ($products['Product']['products_commissionType'] == '$') ? '$' : NULL;
$percent = ($products['Product']['products_commissionType'] == '%') ? '%' : NULL;
?>
<?php if ($products): ?>
    <?php
    $breadcrumsubc = $this->requestAction('/products/breadcrumchkHasParent/' . $products['Product']['category_id']);
    if ($breadcrumsubc['label'] == 1) {
        $this->Html->addCrumb($breadcrumsubc['catname_label1'], '/products/browsebycategory/' . $breadcrumsubc['catid_label1'], array('escape' => false));
    } elseif ($breadcrumsubc['label'] == 2) {
        $this->Html->addCrumb($breadcrumsubc['catname_label1'], '/products/browsebycategory/' . $breadcrumsubc['catid_label1'], array('escape' => false));
        $this->Html->addCrumb($breadcrumsubc['catname_label2'], '/products/browsebycategory/' . $breadcrumsubc['catid_label2'], array('escape' => false));
    } elseif ($breadcrumsubc['label'] == 3) {
        $this->Html->addCrumb($breadcrumsubc['catname_label1'], '/products/browsebycategory/' . $breadcrumsubc['catid_label1'], array('escape' => false));
        $this->Html->addCrumb($breadcrumsubc['catname_label2'], '/products/browsebycategory/' . $breadcrumsubc['catid_label2'], array('escape' => false));
        $this->Html->addCrumb($breadcrumsubc['catname_label3'], '/products/browsebycategory/' . $breadcrumsubc['catid_label3'], array('escape' => false));
    } elseif ($breadcrumsubc['label'] == 4) {
        $this->Html->addCrumb($breadcrumsubc['catname_label1'], '/products/browsebycategory/' . $breadcrumsubc['catid_label1'], array('escape' => false));
        $this->Html->addCrumb($breadcrumsubc['catname_label2'], '/products/browsebycategory/' . $breadcrumsubc['catid_label2'], array('escape' => false));
        $this->Html->addCrumb($breadcrumsubc['catname_label3'], '/products/browsebycategory/' . $breadcrumsubc['catid_label3'], array('escape' => false));
        $this->Html->addCrumb($breadcrumsubc['catname_label4'], '/products/browsebycategory/' . $breadcrumsubc['catid_label4'], array('escape' => false));
    }
    $this->Html->addCrumb('Product Details');
    ?>
    <div id="loader_cart" style="display:none;left:392px;position:absolute;top:240px;"><img src="<?php echo Configure::read('base_url'); ?>img/animation_processing.gif" alt="Processing Cart..." style="" /></div>

    <div class="search-title">
        <div style="float:left;">Items: <?php echo $products['Product']['products_title']; ?></div>
        <div style="float:right;margin-right:6px;">Item Number: <?php echo $products['Product']['id']; ?></div>
    </div>
    <div class="product-details">
        <div class="product-info">
            <div class="product-info-left">
                <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
                    <tr>
                        <td width="31%"><b>Price:</b></td>
                        <td width="19%" <?php //if($commition['priceChange']):class="line-through" ?><?php //endif; ?>>$<?php echo $products['Product']['products_price']; ?></td>
                        <td width="6%"><b>Qty:</b></td>
                        <td width="43%">
                     <?php if ($products['Product']['products_quantity'] > 0): ?>
                                <select name="data[quqntity]" id="product_qty">
                                <?php for ($i = 1; $i <= $products['Product']['products_quantity']; $i++): ?>
                                        <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                                    <?php endfor; ?>
                                </select>
                                <?php else: ?>
                                &nbsp;Out of Stock
                            <?php endif; ?>
                            <?php if ($products['Product']['use_paypal'] == 'Yes'): ?>
                                <img src="<?php echo $this->webroot; ?>img/icon-paypal.gif" width="66" height="19" alt="Paypal" style="padding:10px 0 0 10px;" />
                            <?php endif; ?>
                            <?php if ($products['Product']['use_google_checkout'] == 'Yes'): ?>              
                                <img src="<?php echo $this->webroot; ?>img/icon-google.gif" width="64" height="24" alt="Google" class="spacingtop-10" />
                            <?php endif; ?>
                        </td>
                    </tr>

                 <?php if ($commition['hasNegotiation']): ?>
                        <tr>
                            <td><b>Negotiated Price:</b></td>
                            <td colspan="3"><?php echo $commition['hasNegotiation']; ?></td>
                        </tr>
                <?php endif; ?>                 

                    <!--  Shipping  -->
                    <tr>
                        <td colspan="4"><b>Shipping Methods:</b></td>
                    </tr>
                    <tr>

                        <td colspan="4">
                            <table border="0" class="shipping" cellspacing="5" cellpadding="0">
                                <!-- Domestic -->
                                <?php if (count($domesticShipping) > 0): ?>
                                    <tr>
                                        <td colspan="2"><b><u>Domestic Shipping Methods</u></b></td>
                                    </tr>
                                    <tr>
                                        <td><b>Method Name</b></td>
                                        <td width="40"><b>Cost</b></td>
                                    </tr>
                                <?php foreach ($domesticShipping as $domshipping): ?>
                                        <tr>
                                            <td><?php echo $domshipping['Shipping']['shipping_method']; ?></td>
                                            <td>$<?php echo $products['Category']['shipping_cost']; ?></td>
                                        </tr>
                             <?php endforeach; ?>
                                <?php endif; ?>
                                <!-- Domestic -->
                                <!-- Internatioal -->
                             <?php if (count($internationalShipping) > 0): ?>
                                    <tr>
                                        <td colspan="2"><b><u>International Shipping Methods</u></b></td>
                                    </tr>
                                    <tr>
                                        <td><b>Method Name</b></td>
                                        <td><b>Cost</b></td>
                                    </tr>
                             <?php foreach ($internationalShipping as $intshipping): ?>
                                        <tr>
                                            <td><?php echo $intshipping['Shipping']['shipping_method']; ?></td>
                                            <td>$ <?php echo $intshipping['ProductInternationalShipping']['shipping_cost']; ?></td>
                                        </tr>
                            <?php endforeach; ?>
                                <?php endif; ?>
                                <!-- International -->
                                <?php if (count($internationalShipping) == 0 && count($domesticShipping) == 0): ?>
                                    <tr>
                                        <td colspan="2">No Shipping method for this product</td>
                                    </tr>
                            <?php endif; ?>
                            </table>
                        </td>
                    </tr>
                    <!-- Shipping -->
                    <tr>
                        <td><b>Product Views:</b></td>
                        <td colspan="3"><?php echo $products['Product']['products_views']; ?></td>
                    </tr>
                    <tr>
                        <td><b>Days Left:</b></td>
                        <td colspan="3"><?php echo intval((strtotime($products['Product']['products_expiredDate']) - time()) / 86400); ?></td>
                    </tr>
                    <tr>
                        <td><b>Ending Date:</b></td>
                        <td colspan="3"><?php echo $products['Product']['products_expiredDate']; ?></td>
                    </tr>
                    <tr>
                        <td><b>Date Started:</b></td>
                        <td colspan="3"><?php echo $products['Product']['products_createDate'] ?></td>
                    </tr>
                    <?php if ($session->read('Auth.User.id') != null) { ?>			  
                        <tr>
                            <td colspan="2"><a href="javascript:void(0);" onclick="showPop(this)" title="Ask a Question" action="ask_a_question" controller="products" elmid="<?php echo $products['Product']['id']; ?>">Ask a Question</a></td>
                            <td colspan="2">&nbsp;</td>
                        </tr>
                        <tr>
                            <td colspan="2"><a href="javascript:void(0);" onclick="showPop(this)" title="Ask a Question" action="report_problem" controller="products" elmid="<?php echo $products['Product']['id']; ?>">Report item</a></td>
                            <td colspan="2">&nbsp;</td>
                        </tr>
                    <?php } else { ?>
                        <tr>
                            <td colspan="2"><a href="javascript:void(0);" onclick="showPop(this)" title="Ask a Question" action="popup_login" controller="users" >Ask a Question</a></td>
                            <td colspan="2">&nbsp;</td>
                        </tr>
                        <tr>
                            <td colspan="2"><a href="javascript:void(0);" onclick="showPop(this)" title="login" action="popup_login" controller="users" >Report item</a></td>
                            <td colspan="2">&nbsp;</td>
                        </tr>
                    <?php } ?>
                </table>
            </div>
            <div class="product-info-right">
                <div class="right-icon">

                </div>
                    <?php if ($products['User']['id'] != $session->read('Auth.User.id')): ?>
                    <div id="fl_menu" class="btn-list">
                    <?php if ($session->read('Auth.User.id') != null) { ?>			  
                            <?php if ($products['Product']['products_quantity'] > 0): ?>
                                <input class="button" type="button" value="Add to Cart" name="add_to_cart" id="add_to_cart" pid="<?php echo $products['Product']['id']; ?>" />
                            <?php endif; ?>
                            <input class="button" type="button" value="Add to Wishlist"  name="add_to_wishlists" id="add_to_wishlists" pid="<?php echo $products['Product']['id']; ?>" />
                            <input class="button" type="button" value="Negotiate" name="" size="10" onclick="showPop(this)" title="negotiate" action="negotiate" elmid="<?php echo $products['Product']['id']; ?>" controller="products" />
                            <?php }else { ?>	
                            <?php if ($products['Product']['products_quantity'] > 0): ?>
                                <input class="button" type="button" value="Add to Cart" name="add_to_cart" id="add_to_cart" pid="<?php echo $products['Product']['id']; ?>" />
                            <?php endif; ?>
                            <input class="button" type="button" value="Add to Wishlist"  name="" size="20" onclick="showPop(this)" title="login" action="popup_login" controller="users" />
                            <input class="button" type="button" value="Negotiate" name="" size="10" onclick="showPop(this)" title="login" action="popup_login" controller="users" />
                            <?php } ?>
                    </div>
                    <?php endif; ?>
                <div class="customer-location">
                    <div class="section-01" style="margin-bottom: 25px;">
                        <h2>Seller Details</h2>
                        <p><b>User Id :</b> <?php echo $products['User']['username']; ?></p>
                        <p><b>Level :</b> <?php echo $products['User']['Group']['name']; ?></p>
                        <p><b>Location :</b> <?php echo $products['User']['City']['name']; ?>, <?php echo $products['User']['State']['name'] . ' ' . $products['User']['Country']['name']; ?></p>
                        <p><b>Active since :</b> <?php echo date('F Y', strtotime($products['User']['created'])); ?></p>
                        <p><b>Total Transactions :</b><?php echo $products['Product']['product_totalsell']; ?></p>
                        <?php echo $this->Html->link('View Seller\'s Store', array('controller' => 'products', 'action' => 'store', $products['User']['id']), array('class' => 'bold-link')); ?>
                    </div>
                    <div class="section-02">
                        <h2 align="left">Feedback</h2>
                            <?php if (count($productRating) > 0) { ?>
                            <div class="separator">	                    
                                <p class="label-text">Accurate Description :</p>
                             <?php if (isset($productRating['Desc_accurate'])): ?>
                                    <p class="rating-status">
                                    <?php for ($i = 0; $i < $productRating['Desc_accurate']['value']; $i++): ?>
                                            <img src="<?php echo $this->webroot; ?>img/<?php echo $productRating['Desc_accurate']['class']; ?>.gif" width="17" height="15" alt="" />
                                        <?php endfor; ?>
                                    </p>
                                    <?php endif; ?>
                            </div>
                            <div class="separator">
                                <p class="label-text">Communication :</p>                     
                             <?php if (isset($productRating['Desc_communication'])): ?>
                                    <p class="rating-status">
                                    <?php for ($i = 0; $i < $productRating['Desc_communication']['value']; $i++): ?>
                                            <img src="<?php echo $this->webroot; ?>img/<?php echo $productRating['Desc_communication']['class']; ?>.gif" width="17" height="15" alt="" />
                                        <?php endfor; ?>
                                    </p>
                                    <?php endif; ?>
                            </div>
                            <div class="separator">
                                <p class="label-text">Shipping Speed :</p>
                             <?php if (isset($productRating['Desc_shipping_speed'])): ?>
                                    <p class="rating-status">
                                    <?php for ($i = 0; $i < $productRating['Desc_shipping_speed']['value']; $i++): ?>
                                            <img src="<?php echo $this->webroot; ?>img/<?php echo $productRating['Desc_shipping_speed']['class']; ?>.gif" width="17" height="15" alt="" />
                                        <?php endfor; ?>
                                    </p>
                                    <?php endif; ?>
                            </div>
                            <div class="separator">
                                <p class="label-text">Would you recommend this Seller :</p>
                             <?php if (isset($productRating['Desc_recommend_seller'])): ?>
                                    <p class="rating-status">
                                    <?php for ($i = 0; $i < $productRating['Desc_recommend_seller']['value']; $i++): ?>
                                            <img src="<?php echo $this->webroot; ?>img/<?php echo $productRating['Desc_recommend_seller']['class']; ?>.gif" width="17" height="15" alt="" />
                                        <?php endfor; ?>
                                    </p>
                                    <?php endif; ?>
                            </div>
                            <div class="separator">
                             <?php if ($session->read('Auth.User.id') != null): ?>
                                    <p class="rating-status"><input type="button" value="Add to Favorite Seller" name="add_to_favorite_seller"/></p>
                                <?php endif; ?>
                            </div>
                            <?php } else { ?>
                            <p>Seller has not received enough feedback for the average</p>
                        <?php } ?>
                    </div>

                </div>
            </div>
        </div>
        <?php if ($session->read('Auth.User.id') != null): ?>
            <?php
            if ($alreadybuy > 0) {
                echo $this->element('details/linksforbuyer');
            }          
            ?>
        <?php endif; ?>
        <?php if ($products['ProductImage']): ?>
            <div class="image-slider">
                <h2  class="search-title">Images</h2>
                <div class="image-thumb">
                    <ul>
                         <?php foreach ($products['ProductImage'] as $images): ?>
                            <li><a href="javascript:void(0);">
                            <?php
                            echo $html->image('thumbs/' . $thumbnail->render($images['image'], array(
                                        'path' => 'thumbs',
                                        'width' => 140,
                                        'height' => 140,
                                        'quality' => 80
                                            )
                                    ), array("border" => 0)
                            );
                            ?>
                                <?php endforeach; ?>
                            </a>       
                        </li>
                    </ul>
                </div>
                <div class="image-content">
                    <?php $j = 0; ?>
                    <?php foreach ($products['ProductImage'] as $image) { ?>
                        <img src="<?php echo $this->webroot; ?>img/uploads/<?php echo $image['image']; ?>"  alt="<?php echo $products['Product']['products_title']; ?>" <?php if ($j == 0): ?>style="display:block" <?php endif; ?> />
                        <?php $j++;
                    } ?>
                </div>         
            </div>
                <?php endif; ?>
        <br style="clear:both;">   
        <div class="bottom-style">         
            <div class="search-title">Item Specifics</div>
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table-info-1">
                <tr>
                    <td width="50%">
                        <table>
                            <tr>
                                <td class="specific-item">Item Information</td>
                            </tr>
                            <?php if ($brands['Brand']['brand_description'] != "") { ?>
                                <tr>
                                    <td width="130"><b style="font-size:14px;">Brand:</b></td>
                                    <td><?php echo $brands['Brand']['brand_description']; ?></td>
                                </tr>
                            <?php } ?>
                            <?php if ($conditions['Brand']['brand_description'] != "") { ?>
                                <tr>
                                    <td width="130"><b style="font-size:14px;">Condition:</b></td>
                                    <td><?php echo $conditions['Brand']['brand_description']; ?></td> 
                                </tr>
                        <?php } if ($styles['Brand']['brand_description'] != "") { ?>
                                <tr>
                                    <td width="130"><b style="font-size:14px;">Style:</b></td>
                                    <td><?php echo $styles['Brand']['brand_description']; ?></td>
                                </tr>
                        <?php } ?>			
                        </table>		
                         <?php if (count($productFields) > 0) { ?>
                        <table>	
                               <tr>
                                    <td class="specific-item">Additional Info</td>
                                </tr>
                                <tr>		
                                    <td class="AdditionalFields"></td>
                                </tr>
                        </table>	
                     <?php } ?>
                        <table>	
                            <tr><td style="font-weight:normal;">
                                    <?php if (!empty($products['Product']['products_damage'])) {
                                    echo"<p class='specific-item'>Problem or Defects<br /></p>";
                                    echo $products['Product']['products_damage'];
                                    } ?>
                             </td></tr>
                        </table>
                    </td>
                    <td width="50%">

                        <table>
                            <tr>
                                <td class="specific-item" colspan="2">Size Information</td>
                            </tr>
                            <?php
                            if (isset($this->data['selected_size'])) {
                                echo'<tr><td>';
                                foreach ($this->data['selected_size'] as $size) {
                                    if ($size['ProductSize']['sizelabel_id'] > 0) {
                                        echo $size['Sizelabel']['size_label'];
                                    } else {
                                        echo $size['Sizetitle']['size_title'];
                                    }
                                    echo' : &nbsp;&nbsp;';
                                    echo $size['Sizevalue']['size_value'];
                                }
                                echo"</td></tr>";
                            } else {
                                echo"<tr><td colspan='2'>No Size Information found.</td></tr>";
                            }
                            ?>
                            <tr><td colspan="2">&nbsp;</td></tr>		
                            <tr><td colspan="2" class="AdditionalFields_label"></td></tr>		
                        </table>
                    </td>
                </tr> 
            </table>
            <div class="search-title spacingtop-10">Item Details</div>
            <div class="spacingall-10"><?php echo $products['Product']['products_description']; ?></div>
    <?php if (count($domesticShipping) > 0 OR count($internationalShipping) > 0) { ?>        
                <div class="search-title">Shipping Details</div>
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table-info-1">
                    <tr>
                        <td class="specific-item">Domestic Shipping Info:<br></td>
                    </tr>
                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td colspan="2" align="left"><b style="font-size:13px;">Domestic Shipping Cost:</b> $<?php echo $products['Category']['shipping_cost']; ?></td>
                                </tr>
                                <tr>
                                    <td><b style="font-size:13px;">Available Shipping Service:</b></td>
                                    <td align="left">
                                        <table>
                                             <?php foreach ($domesticShipping as $domShip): ?>
                                                <tr>
                                                    <td><?php echo $domShip['Shipping']['shipping_method']; ?></td>
                                                </tr>
                                              <?php endforeach; ?>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <b style="font-size:13px;">Seller Ships in:</b> <?php echo $products['HandleTime']['handling_time']; ?>
                                            <?php if ($products['Product']['handale_additional_info']): ?>
                                            <br /><br /><div class="spacingall-10"><?php echo $products['Product']['handale_additional_info']; ?></div>
                                        <?php endif; ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <b style="font-size:13px;">Insurance:</b> Included in shipping/handling</td>
                                </tr>
                            </table>
                        </td>        			
                    </tr>
                </table>
        <?php if (count($internationalShipping) > 0) { ?>
                    <table width="100%" cellspacing="0" style="border-top: 1px solid #ccc; margin:20px 0;">
                        <tr>
                            <td><span class="specific-item">International Shipping Info:</span><br>
                                <div class="spacingall-10"><?php if ($products['Product']['international_shipping_additional_info'] != "") {
                echo $products['Product']['international_shipping_additional_info'];
            } ?></div></td>
                        </tr>
                        <tr>
                            <td width="100%" >
                                <div class="internationalshipping">
                                    <table cellspacing="0" width="100%">
                                        <tr><th width="55%" align="left">Shipping Method</th><th width="20%">Location(s)</th><th width="15%">Flat Shipping Cost</th></tr>
                                        <?php foreach ($internationalShipping as $intShip) { ?>
                                            <tr>
                                                <td style="text-align:left;"><?php echo $intShip['Shipping']['shipping_method']; ?></td>
                                                <td style="text-align:center;"><?php echo $intShip['ProductInternationalShipping']['continent_id']; ?></td>
                                                <td style="text-align:center;">$<?php echo $intShip['ProductInternationalShipping']['shipping_cost']; ?></td>	
                                            </tr>
                                        <?php } ?>    
                                    </table>
                                </div>
                            </td>
                        </tr>
                    </table>
                <?php }
            } ?>
            <div class="search-title">Return Policy</div>
            <div class="spacingall-10"><?php echo $returnpolicy; ?>
                <div style="height:70px;"></div>
            </div>
        </div>        
    </div>
    <!--  </div> -->
<?php else: ?>
    <p><b style="font-size:14px;">Sorry! Product details are not available due to any of the following reasons:</b>
    <ul style="margin-left:50px;">
        <li>Item expired</li>
        <li>Product is not available in the system</li>
        <li>Product is not allowed to sell</li>
        <li>Seller has restricted to view product details</li>
    </ul>
    </p>	
<?php endif; ?>
<style>#tooltip{position:absolute;border:1px solid #333;background:#f7f5d1;padding:2px 5px;color:#333;display:none;}</style>